package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPublicationPictureAfterView;
import com.cloudsigns.factorymanager2.engineering.IView.IPublicationPictureBeforeView;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationPictureAfterModel;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationPictureBeforeModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationPictureAfterModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationPictureBeforeModel;

/**
 * Created by tony on 2018/5/30.
 */

public class PublicationPictureAfterPresenter {
    private IPublicationPictureAfterView view;
    private IPublicationPictureAfterModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PublicationPictureAfterPresenter(IPublicationPictureAfterView view) {
        this.view = view;
        this.model = new PublicationPictureAfterModel();
    }

    public void publicationPictureAfter() {

        model.publicationPictureAfter(view.getEngineeringPublicationMediaId(), view.getOrderId(), view.getPicList(), new PublicationPictureAfterModel.OnPublicationPictureAfterListener() {
            @Override
            public void publicationPictureAfterSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationPictureAfterSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void publicationPictureAfterFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationPictureAfterFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
